<template>
  <div class="mvlist">
    <!-- 标题头部 -->
    <div class="mvlist-title">
      <h3>{{ title }} <i class="el-icon-arrow-right"></i></h3>
      <ul class="category" v-if="title == '最新MV'">
        <li
          v-for="(item, index) of category"
          :key="index"
          :style="{ color: item == name ? themeColor : '' }"
          @click="toMvIndex(item)"
        >
          {{ item }}
        </li>
      </ul>
    </div>
    <!-- content内容 -->
    <div class="mvlist-content">
      <div class="mvlist-item" v-for="(item, index) of MvList" :key="index">
        <!-- 图片 -->
        <div class="item-img" @click="toMVdetails(item.id)">
          <div class="mv-playCount">
            <span
              ><i class="iconfont icon-luxiang2"></i
              >{{ item.playCount | playCount }}</span
            >
          </div>
          <img :src="item.cover" alt="" />
        </div>
        <!-- 名字 标题 -->
        <div class="item-name">
          <p class="item-title" :title="item.name">{{ item.name }}</p>
          <p
            class="name"
            :title="item.artistName"
            @click.stop="toSingerDetails(item.artistId)"
          >
            {{ item.artistName }}
          </p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "MvList",
  components: {},
  props: {
    MvList: {
      type: [Object, Array, String]
    },
    title: {
      type: String
    }
  },
  data() {
    return {
      category: ["全部", "内地", "港台", "欧美", "日本", "韩国"], // 分类
      name: "全部"
    };
  },
  computed: {
    themeColor() {
      return this.$store.state.themeColor;
    }
  },
  watch: {
    $route() {
      this.name =
        this.$route.query.cat !== undefined ? this.$route.query.cat : "全部";
    }
  },
  created() {
    this.name =
      this.$route.query.cat !== undefined ? this.$route.query.cat : "全部";
  },
  mounted() {},
  methods: {
    toMvIndex(cat) {
      this.name = cat;
      this.$router.push({
        name: "mvlist",
        query: {
          cat
        }
      });
    },
    toSingerDetails(id) {
      this.$router.push({
        name: "singerdetails",
        query: {
          id
        }
      });
    },
    toMVdetails(id) {
      this.$router.push({
        name: "mvdetails",
        query: {
          id
        }
      });
    }
  }
};
</script>

<style scoped lang="scss">
.mvlist {
  margin-top: 1.875rem;
  .mvlist-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    h3 {
      font-size: 1.125rem;
      cursor: pointer;
    }
    .category {
      display: flex;
      list-style: none;
      align-items: center;
      font-size: 0.875rem;
      li {
        cursor: pointer;
        width: 3.75rem;
        height: 1.875rem;
        text-align: center;
        line-height: 1.875rem;
      }
    }
  }
  .mvlist-content {
    display: flex;
    flex-wrap: wrap;
    margin-top: 1.875rem;
    .mvlist-item {
      width: 25%;
      padding: 0.3125rem 0.625rem;
      box-sizing: border-box;
      .item-img {
        position: relative;
        width: 100%;
        height: 10.625rem;
        img {
          width: 100%;
          height: 100%;
          border-radius: 0.3125rem;
          cursor: pointer;
        }
        .mv-playCount {
          position: absolute;
          top: 0;
          right: 0;
          padding: 0.125rem 0.5rem;
          color: #fff;
          .icon-luxiang2 {
            font-size: 1.25rem;
            vertical-align: middle;
          }
        }
      }
      .item-name {
        color: #555555;
        padding: 0.3125rem 0;
        .item-title:hover {
          color: #000;
        }
        .item-title {
          cursor: pointer;
          font-size: 0.875rem;
          display: -webkit-box;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 1;
          overflow: hidden;
        }
        .name {
          color: #ccc;
          cursor: pointer;
          margin-top: 0.1875rem;
          display: -webkit-box;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 1;
          overflow: hidden;
        }
        .name:hover {
          color: #aaaaaa;
        }
      }
    }
  }
}
</style>
